package com.ruoyi.common.core.utils;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;

import java.util.Date;

/**
 * FastIDUtil
 *
 * @author Administrator
 * @date 2023/03/09
 */
public class FastIDUtil {
    public static String randomTimeId() {
        String year = Integer.valueOf(DateUtil.year(new Date())).toString();
        String month = Integer.valueOf(DateUtil.month(new Date())).toString();
        String day = Integer.valueOf(DateUtil.dayOfMonth(new Date())).toString();
        String hour = Integer.valueOf(DateUtil.hour(new Date(), true)).toString();
        String minute = Integer.valueOf(DateUtil.minute(new Date())).toString();
        String second = Integer.valueOf(DateUtil.second(new Date())).toString();
        String millSecond = Integer.valueOf(DateUtil.millisecond(new Date())).toString();
        String randomNumbers = RandomUtil.randomNumbers(3);
        return year + month + day + hour + minute + second + millSecond + randomNumbers;
    }

    public static String todayStr() {
        String weekOfYear = String.format("%02d", DateUtil.thisWeekOfYear());
        String dayOfMonth = String.format("%02d", DateUtil.thisDayOfMonth());
        String year = String.valueOf(DateUtil.thisYear())
            .substring(String.valueOf(DateUtil.thisYear()).length() - 2);
        //22112201
        return String.format("%s%s%s", year, weekOfYear, dayOfMonth);

    }

    public enum Scene {
        Other("O", 0),
        Tangshi("D", 1),
        Kuaican("K", 2),
        Waimai("T", 3),
        Booking("YD", 4),
        HangBill("HB", 7),
        Bill("PAY", 8),
        Check("Ck", 9);
        private final String key;
        private final Integer code;

        Scene(String key, Integer code) {
            this.key = key;
            this.code = code;
        }

        public static Scene getValueByCode(Integer code) {
            for (Scene scene : Scene.values()) {
                if (code.equals(scene.code)) {
                    return scene;
                }
            }
            return null;
        }

    }
}
